package com.loe.ktui.custom

import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import com.loe.ktui.UiGroup
import org.json.JSONObject

open class UiLinearJsonList(id: String? = null) : UiLinearList<JSONObject>(id)
{
    /** 创建view */
    override fun createView(context: Context, parent: ViewGroup?): KtLinearJsonListView
    {
        return KtLinearJsonListView(context).also()
        {
            initUI(context, it)
            addToParent(parent, it)
        }
    }
}

fun Any.ui_LinearJsonList(id: String? = null, block: (UiLinearJsonList.() -> Unit)? = null): UiLinearJsonList
{
    val ui = UiLinearJsonList(id)
    block?.let { ui.it() }
    if (this is UiGroup) addChild(ui)
    return ui
}

open class KtLinearJsonListView : KtLinearListView<JSONObject>
{
    constructor(context: Context) : super(context)
    {
        initView()
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
    {
        initView()
    }

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
    {
        initView()
    }

    private fun initView()
    {
    }
}